package org.emet.log;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 */
@Aspect
public class PerformanceAspect {

	@Pointcut("execution(public * org.emet.service.*.*(..)) ")
	public void monMethod() {
	}

	@Around("monMethod()")
	public Object traceAround(ProceedingJoinPoint pjp) throws Throwable {
		long start = System.currentTimeMillis();
		try {
			return pjp.proceed();
		} finally {
			System.err.println(pjp.getClass().getName() + "->" + pjp.getSignature().toShortString() + ":"
					+ ((System.currentTimeMillis() - start)));
		}
	}

}
